using CQRSDemo.Api;
using CQRSDemo.Application.Behaviors;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var assembly = RuntimeHelper.GetAllAssemblies();
builder.Services.AddMediatR(config =>
{
    config.RegisterServicesFromAssemblies(assembly.ToArray());
    config.AddOpenBehavior(typeof(LoggingBehavior<,>));
});

var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();